# -*-coding:utf-8-*-
import sqlite3 as sql
import math as mt
import time
import pandas as pd  	
import random

conn = sql.connect('F:\\test.db')
cursor = conn.cursor()

#创建表
try:
	create_table_user = 'create table num1 (id int(25) primary key, name varchar(250), phone int(20))'
	cursor.execute(create_table_user)
	conn.commit()
except sql.OperationalError as e:
	print('There is something wrong: ', e)
	pass

# 生成数据
word = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
rand_num = random.randrange(0,26)
def name():
	name = ''
	for i in  range(5):   	
		rand_num = random.randrange(0,26)  	
		one = word[rand_num]
		name = name +one
	return name

num = ['0','1','3','4','5','6','7','8','9']
def phone():
	num_one = ''
	for i in range(7):
		rand_num = random.randrange(0,7)
		num_one = num_one +num[rand_num]
	return int(num_one)

#插入数据
for i in range(200,301):
	insert = "insert into num1 (id, name, phone) values "+ "({0},'{1}','{2}')".format(i, name(), phone())
	print(insert)
	cursor.execute(insert)
	conn.commit()

# 查询数据
select = 'select * from num where id >200'
cursor.execute(select)
conn.commit()
print(cursor.fetchall())

conn.close()
	

